package com.mt.grand.proxy.custom;

import com.mt.grand.proxy.dto.Person;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class CustomMeipo implements GPInvocationHandler{

    Person target;

    public Object getProxyInstance(Person target){
        this.target = target;
        Class<?> clazz = target.getClass();
        return GPProxy.newProxyInstance(new GPClassLoader(),clazz.getInterfaces(),this);
    }

    @Override
    public Object invoke(Object gpProxy, Method method, Object[] args) throws InvocationTargetException, IllegalAccessException {
        System.out.println("我是媒婆：我要给你找对象，现在已经拿到你的需求");
        System.out.println("开始物色");

        method.invoke(this.target,args);

        System.out.println("如果合适的话，就准备办事");

        return  null;

    }
}
